package student;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025-02-02
 * Time: 18:34
 */
public class Student implements Comparable<Student> {
    public String name;
    public int age;

    //构建方法
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    //Comparable中compareTo的重写
    //按年龄排序
    @Override
    public int compareTo(Student o) {
        return this.age - o.age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
